﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MainProject
{
    public partial class MainMDIPaarent1 : UTLBASEFORM.MDIPARENT1
    {
        #region "Private Variable"
        string strText = "Đang cập nhật";

        #endregion

        public MainMDIPaarent1()
        {
            InitializeComponent();
        }

        private void MainMDIPaarent_Load(object sender, EventArgs e)
        {
            LoadMenu();
            LoadRate();
            SetMenuWithAuthentication();
        }

        private void LoadRate()
        {

        }

        protected override void SetMenuWithAuthentication()
        {
            switch (userLoginInfo.Authentication)
            {
                case 1:
                    EnableTAB1();
                    EnableTAB2();
                    EnableTAB3();
                    EnableTAB4();
                    EnableTAB5();
                    EnableTAB6();
                    EnableTAB7();
                    EnableTAB8();
                    EnableTAB9();
                    EnableTAB10();
                    EnableTAB11();
                    EnableTAB12();
                    break;
                case 2:
                    DisableTAB1();
                    DisableTAB2();
                    DisableTAB3();
                    DisableTAB4();
                    DisableTAB5();
                    DisableTAB6();
                    DisableTAB7();
                    DisableTAB8();
                    DisableTAB9();
                    DisableTAB10();
                    DisableTAB11();
                    DisableTAB12();
                    break;
                default:
                    break;
            }

        }

        /// <summary>
        /// Show menu ung voi tung user
        /// </summary>
        private void LoadMenu()
        {
            this.ShowTAB1("Sản Phẩm", null);
            this.ShowTAB2("Bán Hàng", null);
            this.ShowTAB3("Tìm Kiếm", null);
            this.ShowTAB4("Tem", null);
            this.ShowTAB5("Báo Cáo", null);
            //this.ShowTAB6("Khách Hàng", null);
            this.ShowTAB7("Nhân Viên", null);
            //this.ShowTAB8("Đơn vị", null);
            this.ShowTAB9("Hệ Thống", null);
            this.ShowTAB10("Kiểm Kho", null);
          //  this.ShowTAB11("Hệ Thống", null);
          //  this.ShowTAB12("Hệ Thống", null);
        }

        protected override void btnOption_Click(object sender, EventArgs e)
        {
            tab9_Click(sender, e);   
        }

        protected override void btnExist1_Click(object sender, EventArgs e)
        {
            if(MessageBox.Show("Bạn có muốn thoát chương trình không?","Hồng Phúc",MessageBoxButtons.YesNo)==DialogResult.Yes)
            {
                Application.Exit();
            }
        }

        protected override void btnAbout_Click(object sender, EventArgs e)
        {
            About _about = new About();
            _about.ShowDialog();
        }

        protected override void tab1_Click(object sender, EventArgs e)
        {
            if (this.ActiveMdiChild != null)
                this.ActiveMdiChild.Close();
            InputProductForm.frmInputProduct frminput = new InputProductForm.frmInputProduct();
            frminput.UserLoginInfo = userLoginInfo;
            MDIChildShow(frminput);
        }
        
        protected override void tab2_Click(object sender, EventArgs e)
        {
            if (this.ActiveMdiChild != null)
                this.ActiveMdiChild.Close();
            SellProductsForm.frmSell frmSell = new SellProductsForm.frmSell();
            frmSell.UserLoginInfo = userLoginInfo;
            MDIChildShow(frmSell);
        }
        /// <summary>
        /// Tim san pham
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void tab3_Click(object sender, EventArgs e)
        {
            if (this.ActiveMdiChild != null)
                this.ActiveMdiChild.Close();
            Search.frmSearch frm = new Search.frmSearch();
            MDIChildShow(frm);
        }
        /// <summary>
        /// Tim don hang
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void tab4_Click(object sender, EventArgs e)
        {
            if (this.ActiveMdiChild != null)
                this.ActiveMdiChild.Close();
            PrintBarcode.print_barcode_new frm = new PrintBarcode.print_barcode_new();
            MDIChildShow(frm);
        }
        /// <summary>
        /// bao cao
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void tab5_Click(object sender, EventArgs e)
        {
            if (this.ActiveMdiChild != null)
                this.ActiveMdiChild.Close();
            ReportForm.frmInventory frm = new ReportForm.frmInventory();
            MDIChildShow(frm);
            
        }
        /// <summary>
        /// Tim nhan vien
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void tab6_Click(object sender, EventArgs e)
        {
            //base.tab3btn4_Click(sender, e);
            MessageBox.Show(strText, "Hồng Phúc");
        }
        /// <summary>
        /// Event cho form quan ly nhan vien
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void tab7_Click(object sender, EventArgs e)
        {
            if (this.ActiveMdiChild != null)
                this.ActiveMdiChild.Close();
            EmployeeForm.frmEmployee _frmEmployee = new EmployeeForm.frmEmployee();
            MDIChildShow(_frmEmployee);
        }
        /// <summary>
        /// Event cho form fdon vi tinh
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void tab8_Click(object sender, EventArgs e)
        {
            if (this.ActiveMdiChild != null)
                this.ActiveMdiChild.Close();
            UnitForm.UnitForm _UnitForm = new UnitForm.UnitForm();
            _UnitForm.UserLoginInfo = userLoginInfo;
            MDIChildShow(_UnitForm);
        }
        /// <summary>
        /// Event cho form cau hinh
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected override void tab9_Click(object sender, EventArgs e)
        {
            if (this.ActiveMdiChild != null)
                this.ActiveMdiChild.Close();
            ConfigForm.ConfigForm _ConfigForm = new ConfigForm.ConfigForm();
            _ConfigForm.UserLoginInfo = userLoginInfo;
            MDIChildShow(_ConfigForm);

        }

        protected override void tab10_Click(object sender, EventArgs e)
        {
            if (this.ActiveMdiChild != null)
                this.ActiveMdiChild.Close();
            frmKiemKho.frmKiemKho frm = new frmKiemKho.frmKiemKho();
            MDIChildShow(frm);
        }

    }
}
